//
//  Team9ExpertFootView.m
//  Team9Project
//
//  Created by 朱嘉祺 on 15/10/17.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9ExpertFootView.h"
#import "Team9Header.h"
#import "Team9JQHeader.h"
#import "Team9ExpertUser_home_infoModel.h"
#import "Team9ExpertIdeabookCollectionVC.h"
#import "Team9FaceViewController.h"
#import "Team9FlowerViewController.h"

@interface Team9ExpertFootView ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, strong)UITableView *tableView;

@end
@implementation Team9ExpertFootView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)setModel:(Team9ExpertUser_home_infoModel *)model{
    if (_model != model) {
        _model = model;
        [self.tableView reloadData];
    }
}
- (void)createView{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 40 * 3 * WIDTH / 375) style:UITableViewStylePlain];
    [self addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.rowHeight = 40 * WIDTH/ 375;
    _tableView.bounces = NO;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if ([Team9EveningType shareEvening].eveningFailling) {
            cell.backgroundColor = [UIColor blackColor];
            cell.textLabel.textColor = [UIColor whiteColor];
        } else {
            cell.backgroundColor = [UIColor whiteColor];
            cell.textLabel.textColor = [UIColor blackColor];
        }
        cell.textLabel.font = [UIFont systemFontOfSize:14 * WIDTH / 375];
    }
    switch (indexPath.row) {
        case 0:
            cell.imageView.image = [UIImage imageNamed:@"fen"];
            cell.textLabel.text = [NSString stringWithFormat:@"粉丝(%@)", _model.follower_count];
            break;
        case 1:
            cell.imageView.image = [UIImage imageNamed:@"guanzhu"];
            cell.textLabel.text = [NSString stringWithFormat:@"关注(%@)", _model.following_count];
            break;
        case 2:
            cell.imageView.image = [UIImage imageNamed:@"zan"];
            cell.textLabel.text = [NSString stringWithFormat:@"赞过的画册(%@)", _model.col_liking_count];
            break;
        default:
            break;
    }
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (!self.Id || !self.vc) {
        return;
    }
    self.vc.hidesBottomBarWhenPushed = YES;
    
    if (indexPath.row == 0) {
        Team9FlowerViewController *faceVC = [Team9FlowerViewController new];
        faceVC.url = [NSString stringWithFormat:@"http://api.meilijia.com/app/user_home_follower_list?page=1&user_id=%@", _Id];
        [self.vc.navigationController pushViewController:faceVC animated:YES];
    }
    if (indexPath.row == 1) {
        Team9FaceViewController *faceVC = [Team9FaceViewController new];
        faceVC.url = [NSString stringWithFormat:@"http://api.meilijia.com/app/user_home_following_list?page=1&user_id=%@", _Id];
        [self.vc.navigationController pushViewController:faceVC animated:YES];
    }
    if (indexPath.row == 2) {
        Team9ExpertIdeabookCollectionVC *team9VC = [Team9ExpertIdeabookCollectionVC new];
        team9VC.url = [NSString stringWithFormat:@"http://api.meilijia.com/app/user_home_liking_collections?page=1&user_id=%@", _Id];
//        NSLog(@"%@", team9VC.url);
        [self.vc.navigationController pushViewController:team9VC animated:YES];
    }
}
@end
